package com.datas.controller;

import com.datas.beans.*;
import com.datas.service.GuanlianService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by jige0727 on 2017/6/19.
 */
@Controller
@RequestMapping(value = "/guanlian", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public class GuanlianController {
    @Autowired
    GuanlianService guanlianService;

    @ResponseBody
    @RequestMapping(value = "/role_pageres")
    public String role_pageres(@RequestBody GL_role_pageres guanlian) {
        Integer res = guanlianService.setGL_role_pageresource(guanlian.getRoleId(), guanlian.getPageResId());
        return new ActResult(res, "操作完成", "错误").toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "/user_dept")
    public String user_dept(@RequestBody GL_user_dept guanlian) {
        Integer res = guanlianService.setGL_user_department(guanlian.getUserId(), guanlian.getDeptId());
        return new ActResult(res, "操作完成", "错误").toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "/user_mng_dept")
    public String user_mng_dept(@RequestBody GL_user_mng_dept guanlian) {
        Integer res = guanlianService.setGL_user_mng_department(guanlian.getUserId(), guanlian.getDeptId());
        return new ActResult(res, "操作完成", "错误").toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "/user_role")
    public String user_role(@RequestBody GL_user_role guanlian) {
        Integer res = guanlianService.setGL_user_role(guanlian.getUserId(), guanlian.getRoleId());
        return new ActResult(res, "操作完成", "错误").toJSONString();
    }
}
